#include <Arduino.h>
#include <WiFi.h>

#define LED 2

// 按钮中断
#define BUTTON_INTRUPT 21

int ledStatus = 1;

int buttonLastTime = 0;

void callback()
{
  // 消除抖动
  int currentTime = millis();
  if (currentTime - buttonLastTime > 300)
  {
    buttonLastTime = currentTime;
    ledStatus = !ledStatus;
    digitalWrite(LED, ledStatus);
  }
}

void setup()
{
  pinMode(LED, OUTPUT);
  digitalWrite(LED, 1);

  // 按下按钮时
  attachInterrupt(digitalPinToInterrupt(BUTTON_INTRUPT), callback, RISING);
}

void loop()
{
}
